#include "builders/baseBuilders_test.hpp"

#include "builders/opfilter/opBuilderHelperFilter.hpp"

namespace
{
auto customRefExpected()
{
    return [](const BuildersMocks& mocks)
    {
        EXPECT_CALL(*mocks.ctx, validator());
        EXPECT_CALL(*mocks.validator, hasField(DotPath("ref"))).WillOnce(testing::Return(false));
        return None {};
    };
}

auto typeRefExpected(schemf::Type sType, json::Json::Type jType, bool success = true)
{
    return [=](const BuildersMocks& mocks)
    {
        EXPECT_CALL(*mocks.ctx, validator()).Times(testing::AtLeast(1));
        EXPECT_CALL(*mocks.validator, hasField(DotPath("ref"))).WillOnce(testing::Return(true));
        EXPECT_CALL(*mocks.validator, getJsonType(DotPath("ref"))).WillOnce(testing::Return(jType));
        return None {};
    };
}

} // namespace

namespace filterbuildtest
{
INSTANTIATE_TEST_SUITE_P(
    Builders,
    FilterBuilderTest,
    testing::Values(
        /*** StringEqual ***/
        // Wrong number of arguments
        FilterT({makeValue(R"("str")"), makeValue(R"("str")")}, opfilter::opBuilderHelperStringEqual, FAILURE()),
        FilterT({}, opfilter::opBuilderHelperStringEqual, FAILURE()),
        // Values
        FilterT({makeValue(R"("str")")}, opfilter::opBuilderHelperStringEqual, SUCCESS()),
        FilterT({makeValue("1")}, opfilter::opBuilderHelperStringEqual, FAILURE()),
        FilterT({makeValue(R"(1.1)")}, opfilter::opBuilderHelperStringEqual, FAILURE()),
        FilterT({makeValue(R"(1.0)")}, opfilter::opBuilderHelperStringEqual, FAILURE()),
        FilterT({makeValue(R"(true)")}, opfilter::opBuilderHelperStringEqual, FAILURE()),
        FilterT({makeValue(R"(false)")}, opfilter::opBuilderHelperStringEqual, FAILURE()),
        FilterT({makeValue(R"([])")}, opfilter::opBuilderHelperStringEqual, FAILURE()),
        FilterT({makeValue(R"({})")}, opfilter::opBuilderHelperStringEqual, FAILURE()),
        FilterT({makeValue(R"(null)")}, opfilter::opBuilderHelperStringEqual, FAILURE()),
        // References
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperStringEqual, SUCCESS(customRefExpected())),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringEqual,
                SUCCESS(typeRefExpected(schemf::Type::TEXT, json::Json::Type::String))),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringEqual,
                FAILURE(typeRefExpected(schemf::Type::DOUBLE, json::Json::Type::Number, false))),
        /*** StringNotEqual ***/
        // Wrong number of arguments
        FilterT({makeValue(R"("str")"), makeValue(R"("str")")}, opfilter::opBuilderHelperStringNotEqual, FAILURE()),
        FilterT({}, opfilter::opBuilderHelperStringNotEqual, FAILURE()),
        // Values
        FilterT({makeValue(R"("str")")}, opfilter::opBuilderHelperStringNotEqual, SUCCESS()),
        FilterT({makeValue("1")}, opfilter::opBuilderHelperStringNotEqual, FAILURE()),
        FilterT({makeValue(R"(1.1)")}, opfilter::opBuilderHelperStringNotEqual, FAILURE()),
        FilterT({makeValue(R"(1.0)")}, opfilter::opBuilderHelperStringNotEqual, FAILURE()),
        FilterT({makeValue(R"(true)")}, opfilter::opBuilderHelperStringNotEqual, FAILURE()),
        FilterT({makeValue(R"(false)")}, opfilter::opBuilderHelperStringNotEqual, FAILURE()),
        FilterT({makeValue(R"([])")}, opfilter::opBuilderHelperStringNotEqual, FAILURE()),
        FilterT({makeValue(R"({})")}, opfilter::opBuilderHelperStringNotEqual, FAILURE()),
        FilterT({makeValue(R"(null)")}, opfilter::opBuilderHelperStringNotEqual, FAILURE()),
        // References
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperStringNotEqual, SUCCESS(customRefExpected())),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringNotEqual,
                SUCCESS(typeRefExpected(schemf::Type::TEXT, json::Json::Type::String))),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringNotEqual,
                FAILURE(typeRefExpected(schemf::Type::DOUBLE, json::Json::Type::Number, false))),
        /*** StringLessThan ***/
        // Wrong number of arguments
        FilterT({makeValue(R"("str")"), makeValue(R"("str")")}, opfilter::opBuilderHelperStringLessThan, FAILURE()),
        FilterT({}, opfilter::opBuilderHelperStringLessThan, FAILURE()),
        // Values
        FilterT({makeValue(R"("str")")}, opfilter::opBuilderHelperStringLessThan, SUCCESS()),
        FilterT({makeValue("1")}, opfilter::opBuilderHelperStringLessThan, FAILURE()),
        FilterT({makeValue(R"(1.1)")}, opfilter::opBuilderHelperStringLessThan, FAILURE()),
        FilterT({makeValue(R"(1.0)")}, opfilter::opBuilderHelperStringLessThan, FAILURE()),
        FilterT({makeValue(R"(true)")}, opfilter::opBuilderHelperStringLessThan, FAILURE()),
        FilterT({makeValue(R"(false)")}, opfilter::opBuilderHelperStringLessThan, FAILURE()),
        FilterT({makeValue(R"([])")}, opfilter::opBuilderHelperStringLessThan, FAILURE()),
        FilterT({makeValue(R"({})")}, opfilter::opBuilderHelperStringLessThan, FAILURE()),
        FilterT({makeValue(R"(null)")}, opfilter::opBuilderHelperStringLessThan, FAILURE()),
        // References
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperStringLessThan, SUCCESS(customRefExpected())),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringLessThan,
                SUCCESS(typeRefExpected(schemf::Type::TEXT, json::Json::Type::String))),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringLessThan,
                FAILURE(typeRefExpected(schemf::Type::DOUBLE, json::Json::Type::Number, false))),
        /*** StringLessThanOrEqual ***/
        // Wrong number of arguments
        FilterT({makeValue(R"("str")"), makeValue(R"("str")")},
                opfilter::opBuilderHelperStringLessThanEqual,
                FAILURE()),
        FilterT({}, opfilter::opBuilderHelperStringLessThanEqual, FAILURE()),
        // Values
        FilterT({makeValue(R"("str")")}, opfilter::opBuilderHelperStringLessThanEqual, SUCCESS()),
        FilterT({makeValue("1")}, opfilter::opBuilderHelperStringLessThanEqual, FAILURE()),
        FilterT({makeValue(R"(1.1)")}, opfilter::opBuilderHelperStringLessThanEqual, FAILURE()),
        FilterT({makeValue(R"(1.0)")}, opfilter::opBuilderHelperStringLessThanEqual, FAILURE()),
        FilterT({makeValue(R"(true)")}, opfilter::opBuilderHelperStringLessThanEqual, FAILURE()),
        FilterT({makeValue(R"(false)")}, opfilter::opBuilderHelperStringLessThanEqual, FAILURE()),
        FilterT({makeValue(R"([])")}, opfilter::opBuilderHelperStringLessThanEqual, FAILURE()),
        FilterT({makeValue(R"({})")}, opfilter::opBuilderHelperStringLessThanEqual, FAILURE()),
        FilterT({makeValue(R"(null)")}, opfilter::opBuilderHelperStringLessThanEqual, FAILURE()),
        // References
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperStringLessThanEqual, SUCCESS(customRefExpected())),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringLessThanEqual,
                SUCCESS(typeRefExpected(schemf::Type::TEXT, json::Json::Type::String))),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringLessThanEqual,
                FAILURE(typeRefExpected(schemf::Type::DOUBLE, json::Json::Type::Number, false))),
        /*** StringGreaterThan ***/
        // Wrong number of arguments
        FilterT({makeValue(R"("str")"), makeValue(R"("str")")}, opfilter::opBuilderHelperStringGreaterThan, FAILURE()),
        FilterT({}, opfilter::opBuilderHelperStringGreaterThan, FAILURE()),
        // Values
        FilterT({makeValue(R"("str")")}, opfilter::opBuilderHelperStringGreaterThan, SUCCESS()),
        FilterT({makeValue("1")}, opfilter::opBuilderHelperStringGreaterThan, FAILURE()),
        FilterT({makeValue(R"(1.1)")}, opfilter::opBuilderHelperStringGreaterThan, FAILURE()),
        FilterT({makeValue(R"(1.0)")}, opfilter::opBuilderHelperStringGreaterThan, FAILURE()),
        FilterT({makeValue(R"(true)")}, opfilter::opBuilderHelperStringGreaterThan, FAILURE()),
        FilterT({makeValue(R"(false)")}, opfilter::opBuilderHelperStringGreaterThan, FAILURE()),
        FilterT({makeValue(R"([])")}, opfilter::opBuilderHelperStringGreaterThan, FAILURE()),
        FilterT({makeValue(R"({})")}, opfilter::opBuilderHelperStringGreaterThan, FAILURE()),
        FilterT({makeValue(R"(null)")}, opfilter::opBuilderHelperStringGreaterThan, FAILURE()),
        // References
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperStringGreaterThan, SUCCESS(customRefExpected())),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringGreaterThan,
                SUCCESS(typeRefExpected(schemf::Type::TEXT, json::Json::Type::String))),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringGreaterThan,
                FAILURE(typeRefExpected(schemf::Type::DOUBLE, json::Json::Type::Number, false))),
        /*** StringGreaterThanOrEqual ***/
        // Wrong number of arguments
        FilterT({makeValue(R"("str")"), makeValue(R"("str")")},
                opfilter::opBuilderHelperStringGreaterThanEqual,
                FAILURE()),
        FilterT({}, opfilter::opBuilderHelperStringGreaterThanEqual, FAILURE()),
        // Values
        FilterT({makeValue(R"("str")")}, opfilter::opBuilderHelperStringGreaterThanEqual, SUCCESS()),
        FilterT({makeValue("1")}, opfilter::opBuilderHelperStringGreaterThanEqual, FAILURE()),
        FilterT({makeValue(R"(1.1)")}, opfilter::opBuilderHelperStringGreaterThanEqual, FAILURE()),
        FilterT({makeValue(R"(1.0)")}, opfilter::opBuilderHelperStringGreaterThanEqual, FAILURE()),
        FilterT({makeValue(R"(true)")}, opfilter::opBuilderHelperStringGreaterThanEqual, FAILURE()),
        FilterT({makeValue(R"(false)")}, opfilter::opBuilderHelperStringGreaterThanEqual, FAILURE()),
        FilterT({makeValue(R"([])")}, opfilter::opBuilderHelperStringGreaterThanEqual, FAILURE()),
        FilterT({makeValue(R"({})")}, opfilter::opBuilderHelperStringGreaterThanEqual, FAILURE()),
        FilterT({makeValue(R"(null)")}, opfilter::opBuilderHelperStringGreaterThanEqual, FAILURE()),
        // References
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperStringGreaterThanEqual, SUCCESS(customRefExpected())),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringGreaterThanEqual,
                SUCCESS(typeRefExpected(schemf::Type::TEXT, json::Json::Type::String))),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringGreaterThanEqual,
                FAILURE(typeRefExpected(schemf::Type::DOUBLE, json::Json::Type::Number, false))),
        /*** StringStarts ***/
        // Wrong number of arguments
        FilterT({makeValue(R"("str")"), makeValue(R"("str")")}, opfilter::opBuilderHelperStringStarts, FAILURE()),
        FilterT({}, opfilter::opBuilderHelperStringStarts, FAILURE()),
        // Values
        FilterT({makeValue(R"("str")")}, opfilter::opBuilderHelperStringStarts, SUCCESS()),
        FilterT({makeValue("1")}, opfilter::opBuilderHelperStringStarts, FAILURE()),
        FilterT({makeValue(R"(1.1)")}, opfilter::opBuilderHelperStringStarts, FAILURE()),
        FilterT({makeValue(R"(1.0)")}, opfilter::opBuilderHelperStringStarts, FAILURE()),
        FilterT({makeValue(R"(true)")}, opfilter::opBuilderHelperStringStarts, FAILURE()),
        FilterT({makeValue(R"(false)")}, opfilter::opBuilderHelperStringStarts, FAILURE()),
        FilterT({makeValue(R"([])")}, opfilter::opBuilderHelperStringStarts, FAILURE()),
        FilterT({makeValue(R"({})")}, opfilter::opBuilderHelperStringStarts, FAILURE()),
        FilterT({makeValue(R"(null)")}, opfilter::opBuilderHelperStringStarts, FAILURE()),
        // References
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperStringStarts, SUCCESS(customRefExpected())),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringStarts,
                SUCCESS(typeRefExpected(schemf::Type::TEXT, json::Json::Type::String))),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringStarts,
                FAILURE(typeRefExpected(schemf::Type::DOUBLE, json::Json::Type::Number, false))),
        /*** StringContains ***/
        // Wrong number of arguments
        FilterT({makeValue(R"("str")"), makeValue(R"("str")")}, opfilter::opBuilderHelperStringContains, FAILURE()),
        FilterT({}, opfilter::opBuilderHelperStringContains, FAILURE()),
        // Values
        FilterT({makeValue(R"("str")")}, opfilter::opBuilderHelperStringContains, SUCCESS()),
        FilterT({makeValue("1")}, opfilter::opBuilderHelperStringContains, FAILURE()),
        FilterT({makeValue(R"(1.1)")}, opfilter::opBuilderHelperStringContains, FAILURE()),
        FilterT({makeValue(R"(1.0)")}, opfilter::opBuilderHelperStringContains, FAILURE()),
        FilterT({makeValue(R"(true)")}, opfilter::opBuilderHelperStringContains, FAILURE()),
        FilterT({makeValue(R"(false)")}, opfilter::opBuilderHelperStringContains, FAILURE()),
        FilterT({makeValue(R"([])")}, opfilter::opBuilderHelperStringContains, FAILURE()),
        FilterT({makeValue(R"({})")}, opfilter::opBuilderHelperStringContains, FAILURE()),
        FilterT({makeValue(R"(null)")}, opfilter::opBuilderHelperStringContains, FAILURE()),
        // References
        FilterT({makeRef("ref")}, opfilter::opBuilderHelperStringContains, SUCCESS(customRefExpected())),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringContains,
                SUCCESS(typeRefExpected(schemf::Type::TEXT, json::Json::Type::String))),
        FilterT({makeRef("ref")},
                opfilter::opBuilderHelperStringContains,
                FAILURE(typeRefExpected(schemf::Type::DOUBLE, json::Json::Type::Number, false)))),
    testNameFormatter<FilterBuilderTest>("StringCmp"));
} // namespace filterbuildtest

namespace filteroperatestest
{
INSTANTIATE_TEST_SUITE_P(
    Builders,
    FilterOperationTest,
    testing::Values(
        /*** StringEqual ***/
        FilterT(
            R"({"target": "str"})", opfilter::opBuilderHelperStringEqual, "target", {makeValue(R"("str")")}, SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringEqual,
                "target",
                {makeValue(R"("str2")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringEqual,
                "target",
                {makeValue(R"("2str")")},
                FAILURE()),
        FilterT(
            R"({"target": "str"})", opfilter::opBuilderHelperStringEqual, "target", {makeValue(R"("st")")}, FAILURE()),
        FilterT(
            R"({"target": "str"})", opfilter::opBuilderHelperStringEqual, "target", {makeValue(R"("tr")")}, FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringEqual,
                "notTarget",
                {makeValue(R"("str")")},
                FAILURE()),
        FilterT(R"({"target": 1})", opfilter::opBuilderHelperStringEqual, "target", {makeValue(R"("1")")}, FAILURE()),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str2"})",
                opfilter::opBuilderHelperStringEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "2str"})",
                opfilter::opBuilderHelperStringEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "st"})",
                opfilter::opBuilderHelperStringEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "tr"})",
                opfilter::opBuilderHelperStringEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringEqual,
                "notTarget",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "notRef": "str"})",
                opfilter::opBuilderHelperStringEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": 1, "ref": "1"})",
                opfilter::opBuilderHelperStringEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "1", "ref": 1})",
                opfilter::opBuilderHelperStringEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        /*** StringNotEqual ***/
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeValue(R"("str")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeValue(R"("str2")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeValue(R"("2str")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeValue(R"("st")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeValue(R"("tr")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringNotEqual,
                "notTarget",
                {makeValue(R"("str2")")},
                FAILURE()),
        FilterT(
            R"({"target": 1})", opfilter::opBuilderHelperStringNotEqual, "target", {makeValue(R"("2")")}, FAILURE()),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str2"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "2str"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "st"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "tr"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str2"})",
                opfilter::opBuilderHelperStringNotEqual,
                "notTarget",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "notRef": "str2"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": 1, "ref": "2"})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "1", "ref": 2})",
                opfilter::opBuilderHelperStringNotEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        /*** StringLessThan ***/
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeValue(R"("str")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeValue(R"("str2")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeValue(R"("2str")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeValue(R"("st")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeValue(R"("tr")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThan,
                "notTarget",
                {makeValue(R"("str2")")},
                FAILURE()),
        FilterT(
            R"({"target": 1})", opfilter::opBuilderHelperStringLessThan, "target", {makeValue(R"("2")")}, FAILURE()),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str2"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "2str"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "st"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "tr"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str2"})",
                opfilter::opBuilderHelperStringLessThan,
                "notTarget",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "notRef": "str2"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": 1, "ref": "2"})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "1", "ref": 2})",
                opfilter::opBuilderHelperStringLessThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        /*** StringLessThanOrEqual ***/
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeValue(R"("str")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeValue(R"("str2")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeValue(R"("2str")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeValue(R"("st")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeValue(R"("tr")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "notTarget",
                {makeValue(R"("str")")},
                FAILURE()),
        FilterT(R"({"target": 1})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeValue(R"("1")")},
                FAILURE()),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str2"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "2str"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "st"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "tr"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "notTarget",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "notRef": "str"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": 1, "ref": "1"})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "1", "ref": 1})",
                opfilter::opBuilderHelperStringLessThanEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        /*** StringGreaterThan ***/
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeValue(R"("str")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeValue(R"("str2")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeValue(R"("2str")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeValue(R"("st")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeValue(R"("tr")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "notTarget",
                {makeValue(R"("2str")")},
                FAILURE()),
        FilterT(
            R"({"target": 1})", opfilter::opBuilderHelperStringGreaterThan, "target", {makeValue(R"("0")")}, FAILURE()),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str2"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "2str"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "st"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "tr"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "2str"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "notTarget",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "notRef": "2str"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": 1, "ref": "0"})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "1", "ref": 0})",
                opfilter::opBuilderHelperStringGreaterThan,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        /*** StringGreaterThanOrEqual ***/
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeValue(R"("str")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeValue(R"("str2")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeValue(R"("2str")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeValue(R"("st")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeValue(R"("tr")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "notTarget",
                {makeValue(R"("str")")},
                FAILURE()),
        FilterT(R"({"target": 1})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeValue(R"("1")")},
                FAILURE()),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str2"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "2str"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "st"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "tr"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "notTarget",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "notRef": "str"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": 1, "ref": "1"})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "1", "ref": 1})",
                opfilter::opBuilderHelperStringGreaterThanEqual,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        /*** StringStarts ***/
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeValue(R"("str")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeValue(R"("str2")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeValue(R"("2str")")},
                FAILURE()),
        FilterT(
            R"({"target": "str"})", opfilter::opBuilderHelperStringStarts, "target", {makeValue(R"("st")")}, SUCCESS()),
        FilterT(
            R"({"target": "str"})", opfilter::opBuilderHelperStringStarts, "target", {makeValue(R"("tr")")}, FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringStarts,
                "notTarget",
                {makeValue(R"("str")")},
                FAILURE()),
        FilterT(R"({"target": 1})", opfilter::opBuilderHelperStringStarts, "target", {makeValue(R"("1")")}, FAILURE()),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str2"})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "2str"})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "st"})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "tr"})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringStarts,
                "notTarget",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "notRef": "str"})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": 1, "ref": "1"})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "1", "ref": 1})",
                opfilter::opBuilderHelperStringStarts,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        /*** StringContains ***/
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeValue(R"("str")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeValue(R"("str2")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeValue(R"("2str")")},
                FAILURE()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeValue(R"("st")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeValue(R"("tr")")},
                SUCCESS()),
        FilterT(R"({"target": "str"})",
                opfilter::opBuilderHelperStringContains,
                "notTarget",
                {makeValue(R"("str")")},
                FAILURE()),
        FilterT(
            R"({"target": 1})", opfilter::opBuilderHelperStringContains, "target", {makeValue(R"("1")")}, FAILURE()),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str2"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "2str"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "st"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "tr"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeRef("ref")},
                SUCCESS(customRefExpected())),
        FilterT(R"({"target": "str", "ref": "str"})",
                opfilter::opBuilderHelperStringContains,
                "notTarget",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "str", "notRef": "str"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": 1, "ref": "1"})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected())),
        FilterT(R"({"target": "1", "ref": 1})",
                opfilter::opBuilderHelperStringContains,
                "target",
                {makeRef("ref")},
                FAILURE(customRefExpected()))),
    testNameFormatter<FilterOperationTest>("StringCmp"));
} // namespace filteroperatestest
